from rest_framework import serializers
from goods.models import SPU, GoodsCategory, Brand


class GoodsSPUSerialzier(serializers.ModelSerializer):
    """
    spu序列化器
    """
    brand_id = serializers.IntegerField()
    brand = serializers.StringRelatedField(read_only=True)

    category1_id = serializers.IntegerField()
    category2_id = serializers.IntegerField()
    category3_id = serializers.IntegerField()
    category1 = serializers.StringRelatedField(read_only=True)
    category2 = serializers.StringRelatedField(read_only=True)
    category3 = serializers.StringRelatedField(read_only=True)

    class Meta:
        model = SPU
        fields = '__all__'


class BrandSerialzier(serializers.ModelSerializer):
    class Meta:
        model = Brand
        fields = '__all__'


class CategorieSerialzier(serializers.ModelSerializer):
    """
        分类序列化器
    """

    class Meta:
        model = GoodsCategory
        fields = '__all__'
